<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Generate certificates | ElasticSearch 7.7 权威指南中文版</title>
	<meta name="keywords" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <meta name="description" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <!-- Give IE8 a fighting chance -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
	<link rel="stylesheet" type="text/css" href="../static/styles.css" />
	<script>
	var _link = 'encrypting-communications-certificates.html';
    </script>
</head>
<body>
<div class="main-container">
    <section id="content">
        <div class="content-wrapper">
            <section id="guide" lang="zh_cn">
                <div class="container">
                    <div class="row">
                        <div class="col-xs-12 col-sm-8 col-md-8 guide-section">
                            <div style="color:gray; word-break: break-all; font-size:12px;">原英文版地址: <a href="https://www.elastic.co/guide/en/elasticsearch/reference/7.7/encrypting-communications-certificates.html" rel="nofollow" target="_blank">https://www.elastic.co/guide/en/elasticsearch/reference/7.7/encrypting-communications-certificates.html</a>, 原文档版权归 www.elastic.co 所有<br/>本地英文版地址: <a href="../en/encrypting-communications-certificates.html" rel="nofollow" target="_blank">../en/encrypting-communications-certificates.html</a></div>
                        <!-- start body -->
                  <div class="page_header">
<strong>重要</strong>: 此版本不会发布额外的bug修复或文档更新。最新信息请参考 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html" rel="nofollow">当前版本文档</a>。
</div>
<div id="content">
<div class="breadcrumbs">
<span class="breadcrumb-link"><a href="index.html">Elasticsearch Guide [7.7]</a></span>
»
<span class="breadcrumb-link"><a href="secure-cluster.html">Secure a cluster</a></span>
»
<span class="breadcrumb-link"><a href="encrypting-internode-communications.html">Tutorial: Encrypting communications</a></span>
»
<span class="breadcrumb-node">Generate certificates</span>
</div>
<div class="navheader">
<span class="prev">
<a href="encrypting-internode-communications.html">« Tutorial: Encrypting communications</a>
</span>
<span class="next">
<a href="encrypting-internode.html">Encrypt internode communications »</a>
</span>
</div>
<div class="section xpack">
<div class="titlepage"><div><div>
<h2 class="title">
<a id="encrypting-communications-certificates"></a>Generate certificates<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/x-pack/docs/en/security/securing-communications/tutorial-tls-certificates.asciidoc">edit</a><a class="xpack_tag" href="https://www.elastic.co/subscriptions"></a>
</h2>
</div></div></div>
<p>In a secured cluster, Elasticsearch nodes use certificates to identify themselves when
communicating with other nodes.</p>
<p>The cluster must validate the authenticity of these certificates. The
recommended approach is to trust a specific certificate authority (CA). Thus
when nodes are added to your cluster they just need to use a certificate signed
by the same CA.</p>
<div class="olist orderedlist">
<ol class="orderedlist">
<li class="listitem">
<p>Generate a certificate authority for your cluster.</p>
<p>Run the following command:</p>
<div class="pre_wrapper lang-sh">
<pre class="programlisting prettyprint lang-sh">./bin/elasticsearch-certutil ca</pre>
</div>
<p>You are prompted for an output filename and a password. In this tutorial, we’ll
use the default filename (<code class="literal">elastic-stack-ca.p12</code>).</p>
<p>The output file is a PKCS#12 keystore that contains the public certificate for
your certificate authority and the private key that is used to sign the node
certificates.</p>
<div class="tip admon">
<div class="icon"></div>
<div class="admon_content">
<p>We’ll need to use this file again when we add nodes to the cluster, so
remember its location and password. Ideally you should store the file securely,
since it holds the key to your cluster.</p>
</div>
</div>
<p>For more information about this command, see
<a href="certutil.html" class="ulink" target="_top">elasticsearch-certutil</a>.</p>
</li>
<li class="listitem">
Create a folder to contain certificates in the configuration directory of your
Elasticsearch node. For example, create a <code class="literal">certs</code> folder in the <code class="literal">config</code> directory.
</li>
<li class="listitem">
<p>Generate certificates and private keys for the first node in your cluster.</p>
<p>Run the following command:</p>
<div class="pre_wrapper lang-sh">
<pre class="programlisting prettyprint lang-sh">./bin/elasticsearch-certutil cert \
--ca elastic-stack-ca.p12 \ <a id="CO498-1"></a><i class="conum" data-value="1"></i>
--dns localhost \ <a id="CO498-2"></a><i class="conum" data-value="2"></i>
--ip 127.0.0.1,::1 <a id="CO498-3"></a><i class="conum" data-value="3"></i>
--out config/certs/node-1.p12 <a id="CO498-4"></a><i class="conum" data-value="4"></i></pre>
</div>
<div class="calloutlist">
<table border="0" summary="Callout list">
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO498-1"><i class="conum" data-value="1"></i></a></p>
</td>
<td align="left" valign="top">
<p>The <code class="literal">--ca</code> parameter contains the name of certificate authority that you
generated for this cluster.</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO498-2"><i class="conum" data-value="2"></i></a></p>
</td>
<td align="left" valign="top">
<p>The <code class="literal">--dns</code> parameter contains a comma-separated list of DNS names for the
node.</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO498-3"><i class="conum" data-value="3"></i></a></p>
</td>
<td align="left" valign="top">
<p>The <code class="literal">--ip</code> parameter contains a comma-separated list of IP addresses for the
node.</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO498-4"><i class="conum" data-value="4"></i></a></p>
</td>
<td align="left" valign="top">
<p>The <code class="literal">--out</code> parameter contains the name and location of the generated
certificate. Ideally the file name matches the <code class="literal">node.name</code> value in the
<code class="literal">elasticsearch.yml</code> file.</p>
</td>
</tr>
</table>
</div>
<p>You are prompted to enter the password for your CA. You are also prompted to
create a password for the certificate.</p>
<p>The output file is a PKCS#12 keystore that includes a node certificate, node key,
and CA certificate.</p>
</li>
</ol>
</div>
<div class="tip admon">
<div class="icon"></div>
<div class="admon_content">
<p>The <a href="certutil.html" class="ulink" target="_top">elasticsearch-certutil</a> command has a lot more
options. For example, it can generate Privacy Enhanced Mail (PEM) formatted
certificates and keys. It can also generate certificate signing requests (CSRs)
that you can use to obtain signed certificates from a commercial or
organization-specific certificate authority. However, those options are not
covered in this tutorial.</p>
</div>
</div>
</div>
<div class="navfooter">
<span class="prev">
<a href="encrypting-internode-communications.html">« Tutorial: Encrypting communications</a>
</span>
<span class="next">
<a href="encrypting-internode.html">Encrypt internode communications »</a>
</span>
</div>
</div>

                  <!-- end body -->
                        </div>
                        <div class="col-xs-12 col-sm-4 col-md-4" id="right_col">
                        
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </section>
</div>
<script src="../static/cn.js"></script>
</body>
</html>